/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.saar.penguin.give2.server.alert;

import de.saar.penguin.give2.server.BigBrother;
import de.saar.penguin.give2.server.Instruction;
import de.saar.penguin.give2.server.SaarNlgSystem;

/**
 *
 * @author koller
 */
public class EnteredRegionAlert extends Alert {
    private final String targetRegion;

    public EnteredRegionAlert(SaarNlgSystem nlg, String targetRegion) {
        super(nlg);
        this.targetRegion = targetRegion;
    }

    @Override
    public boolean isActivated(BigBrother bb) {
        return nlg.getDiscretizer().getPositionName(w().getPlayerPosition()).equals(targetRegion);
    }

    @Override
    public Instruction getInstruction() {
        Instruction instr = nlg.instructionGenerator.createInstruction(nlg.visible);
        finished = true;
        return instr;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final EnteredRegionAlert other = (EnteredRegionAlert) obj;
        if ((this.targetRegion == null) ? (other.targetRegion != null) : !this.targetRegion.equals(other.targetRegion)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 97 * hash + (this.targetRegion != null ? this.targetRegion.hashCode() : 0);
        return hash;
    }

    
}


/*
 *   String currentRegion = nlg.getDiscretizer().getPositionName(w().getPlayerPosition());

        if (!currentRegion.equals(previousActivatedRegion)) {
            if( currentRegion.equals(targetRegion))


            previousActivatedRegion = currentRegion;
            return currentRegion.equals(targetRegion);
        } else {
            return false;
        }
 */